//
//  receiveFirCirGetID.m
//  tcpoctest
//
//  Created by gump on 5/6/13.
//  Copyright (c) 2013 gump. All rights reserved.
//

#import "receiveFirCirGetID.h"

#import "FirCirPersonDataSource.h"
#import "FirCirNewsMailDataSource.h"

#import "sendFirCirGetID.h"

#import "FirCirMailNewsdb.h"

@implementation receiveFirCirGetID

-(void)processreceive
{
    //返回 74char(1),8char(1),用户名长度char(1), 用户名char(x),
    //开始位置(int),结束位置(int),[动态ID字串长度char(1),
    //动态ID字串char(x)]*N 时间倒序
    
    NSString *mail = [logicsb ReadUnencodeString];
    [logicsb ReadIntWithTT:NTT_BIG2SMALL];
    int iend = [logicsb ReadIntWithTT:NTT_BIG2SMALL];
    NSString *strid = [logicsb ReadUnencodeString];
    
    if ([[DataControl shareControl].fcPersonDS IsContainInDelArr:strid] == NO) {
        
        [[DataControl shareControl].fcnewsmailDS AddMail:mail
                                              withNewsID:strid];
        [[DataBaseCtrol shareControl].fircirmailnewsdatabase
         insertNewMail:strid withMail:mail];
        
        [[DataControl shareControl].fcPersonDS insertNewsIDToMail:mail
                                                       withNewsID:strid
                                                        withOrder:ORDER_ASC];
    }
    
    
    
    [[DataControl shareControl].fcPersonDS SetYetLength:iend];
    if ([[DataControl shareControl].fcPersonDS YetLength] <
        [[DataControl shareControl].fcPersonDS IDLength]) {
        [[netManager sharedNetManager].sendFCGetID SendFCGetID:mail
                                                      StartPos:
         [[DataControl shareControl].fcPersonDS YetLength]
                                                        EndPos:
         [[DataControl shareControl].fcPersonDS YetLength] + 1];
    }
    
    [[DataControl shareControl].UICommendDS addUICommand:UC_REFRESHCURVIEW];
    
    [self ShowLog];
}

@end
